Random list mechanism
There are many things in the game that follow this mechanism to choose different effect/type randomly such as Golden cookie, Wrath cookie, Force the Hand of Fate, mutation in Garden, and (similar and but not exactly the same) Sugar Lump. Basically the mechanism starts with a pool which contains certain effects. Then it adds different effects to the pool randomly. Finally it chooses one effect from the pool with equal probability. Mutation of Garden At each tick, the game will check every empty plots with every mutation recipes. If certain conditions is satisfied, then there will be corresponding base chance to add the mutate plants into the candidate pool. The final outcome will be chosen from the candidate pool with equal probability. If the soil is Woodchips, the above procedure will loop 3 times at each tick. For example, if an empty plot is surrounded by 8 Queenbeets, there are 3 possible mutation with equal base chance P=0.001, Juicy Queenbeets, Duketaters, and Shriekbulbs. The candidate pool has 2^3=8 possibility and can be grouped into four kinds according to the size. Among the all eight pools, there are four pools contains Shriekbulbs: 1, 2 and 1 belone to G1, G2 and G3 respectively. The probability of picking Shriekbulbs in the pool belong to Gi will be 1/i. After sum over all four pools, we get the total probabiliy of picking Shriekbulbs will be PT=1*P(1-P)^2 + 2*P^2(1-P)/2 + P^3/3 = P-P^2+P^3/3. Since in this case all three mutating plants has the same base chance, there are on the same footing and the probability of picking Duketaters and Juicy Queenbeets will also be P-P^2+P^3/3. If the soil is Woodchips, the probability of mutate Shriekbulbs after three loops will be PT+(1-3PT)P+(1-3PT)^2P = 3p - 12p^2 + 28p^3 - 42p^4 + 42p^5 - 28p^6 + 12p^7 - 3p^8 + p^9/3. Force the Hand of Fate The procedure of Force the Hand of Fate is a little different. For golden cookie, the procedure is: Win: * Add Frenzy and Lucky to a pool. * If there is no Dragonflight buff active, add Click Frenzy. * 10% chance to add Storm, Storm and Blab to the pool. * 25% chance to add Building Special, if the you owned more than or equal to 10 total building. ** For all building of which number more or equal to 10, choose one and buff according to the chosen building's amount. If no building has such quantity, choose Frenzy. * 15% chance to replace the pool with Storm Drop. * 0.01% chance to add Free Sugar Lump to the pool. * Pick a random effect from the list. Note the there is 15% chance that the pool is replaced completely instead of adding something into the pool. To handle this rule properly, consider two cases. First assume that the pool is never replaced. Second, assume that the pool is always replaced: The actual probability will be mix of these two cases. Fail: * Add Clot and Ruin to a pool. * 10% chance to add Cursed Finger, Elder Frenzy to the pool. * 0.3% chance to add Free Sugar Lump to the pool. * 10% chance to replace the pool with Blab. * Pick a random effect from the list. Golden/Wrath cookie For Golden cookie and Wrath cookie, there is an additional rule. Take the procedure of picking effect of golden cookie in version 1.0466 as an example: *Add Frenzy and Lucky to a pool. *3% chance to add Chain to the pool, if at least 100,000 cookies have been baked in this game. *10% chance to add Click Frenzy to the pool. *80% chance to remove the last effect from the pool, if it's there. *0.01% chance to add Blab to the pool. *Pick a random effect from the pool. The rule 5 "80% chance to remove the last effect from the pool, if it's there." makes things more complicated but still doable. First we shall ignore the rule first, and calculate the probability by listing all possible pools as mentioned above. (From now on we shall assume that at least 100,000 cookies have been baked.) Therefore, the probability of picking Frenzy is: P1/5+(P2+P3+P5)/4+(P4+P6+P7)/3+P8/2=0.478568. The probability of picking Lucky is the same as Frenzy. The probability of picking Chain,Click Frenzy and Blab are P5/5+(P2+P3)/4+P4/3=0.00974976, P5/5+(P2+P5)/4+P6/3=0.0330825 and P5/5+(P3+P5)/4+P7/3=0.00003226 respectively. These probabilities are called primitive probabilities. However, due to the rule 5, the actually probability is depend on last cookie. For example, if the last cookie is Frenzy, there are 80% chance that we shall apply the following table. From the table, we can calculate the conditional probability: Remember that the actual probability should be a combination of 20% of primitive probability and 80% of conditional probability: The actual probability of Lucky is the same as Frenzy. For conditional probability of Chain, we shall consider the following table: And the actual probability is: Repeating the process, we can build up the following table. Notice that since we add Blab after rule 5, the conditional/actual probability when last cookie is blab is the same as primitive probability. The table above is a transition matrix, the long term (stationary) probability can be found as the eigenvector of the transition matrix with eigenvalue 1. Using this, we can obtain the following table shows the final result: = For wrath cookies, the procedure of determining effect is different: * Add Lucky, Clot and Ruin to a pool. * 30% chance to add Elder Frenzy and Chain to the pool. * If previous step fails (70%), 3% chance to add Chain to the pool, if at least 100,000 cookies have been baked this game. * 10% chance to add Click Frenzy to the pool. * 80% chance to remove the last effect from the pool, if it's there. * 0.01% chance to add Blab to the pool. * Pick a random effect from the pool. However, the transition matrix can (assuming at least 100,000 cookies have been baked) still be made: And the long term probability can be calculated: The final table then can be obtained: Grandmapocalypse There are four phases in Grandmapocalypse: Appeased, Awoken, Displeased, Angered. For the first phase all the cookie will be golden and for the last phased all cokied will be wrath. In two middle phases, the probability of wrath cookie is 1/3 and 2/3 respectively. Thus the transition matrix of these two phase are a linear combination of transition matrix of Appeased phase (pure golden cookie) and transition matrix of Awoken phase (pure wrath cookie). Let us show the golden transition matrix and wrath transition matrix first: Then combine them in G:W=2:1 (Awoken) and G:W=1:2 (Displeased): The final normalized table are presented below: Sugar Lump Take the type of Sugar Lump considerably different from all above. The type determination procedure is as follows. *Add Normal to a pool. *If you have upgrades Sucralosia Inutilis, 15% chance to add Bifurcated to the pool, otherwise 10% chance to add Bifurcated to the pool. *0.3% chance to add Golden to the pool. *0%, 10%, 20% and 30% to add Meaty to the pool if the game is in Appeased, Awoken, Displeased and Angered phase of Grandmapocalypse respectively. *Pick a random effect from the pool. Unlike the previous example, the random number, which decide whether the candidate should be added into the pool or not, is regenerated at each step. The random number, 0 <1 is generated only once through the whole process. If P i'', then the ''i type will be added to the pool. When P''h''>=P''i''>=P''j''>=P''k'', probability of selecting a h'' type: (P''h-P''i'')+(P''i''-P''j'')/2+(P''j''-P''k'')/3+P''k''/4, i'' type: (P''i-P''j'')/2+(P''j''-P''k'')/3+P''k''/4, j'' type: (P''j-P''k'')/3+P''k''/4 and k'' type: P''k/4. Then we can calculated all the results. Category:Utilities